home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / apps / 356 / applic / getpath.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-02-16  |  971 b   |  33 lines

  1. PROCEDURE GetDriveAndPath(VAR S:string);
  2.   { A procedure that returns a Pascal string containing the current drive,
  3.   current path and all punctuation.  Simply append a raw file name.}
  4.   VAR
  5.     i : integer;
  6.     T : string;
  7.     Path : string;
  8.     DriveString : string;
  9.  
  10.   FUNCTION CurrentDisk:integer;
  11.     {Returns an integer specifying the current drive. 0 specifies A, etc.}
  12.     GEMDOS($19);
  13.  
  14.   PROCEDURE GetDir(VAR Ptr:string; DriveID:integer);
  15.     {Puts a C string defining the folders currently open on DriveID
  16.     into S.  DriveID of 0 specifies the current drive.}
  17.     GEMDOS($47);
  18.  
  19.   BEGIN {getdriveandpath}
  20.     DriveString := CONCAT(CHR(ORD('A')+CurrentDisk),':');
  21.     GetDir(Path,0);
  22.     {Convert from C to Pascal.}
  23.     i := 0;
  24.     WHILE Path[i] <> CHR(0) DO
  25.       BEGIN
  26.         T[i+1] := Path[i];
  27.         i := i+1;
  28.       END;
  29.     {Set the length}
  30.     T[0] := CHR(i);
  31.     S := CONCAT(DriveString,T,'\');
  32.   END {getdriveandpath};
  33.